package cn.hashq.netpoststation.exception;


import cn.hashq.netpoststation.util.LogUtil;
import cn.hashq.netpoststation.vo.ServerResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ResponseBody
    @ExceptionHandler({Exception.class})
    public ServerResponse<String> handException(Exception e) {
        log.error("未知异常:【{}】", LogUtil.convertStackInfoToStr(e));
        return ServerResponse.createFailedResult(e.getMessage());
    }
}
